//
//  AppDelegate.m
//  01-homework
//
//  Created by Snow on 16/7/14.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    _window.rootViewController = [[ViewController alloc] init];
    //添加背景图片
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"welcome_2"]];
    [_window addSubview:imageView];
    imageView.frame = _window.frame;
    imageView.alpha = 0.8;
    imageView.userInteractionEnabled = YES;
    //添加图标(中心)
    UIImageView *imageOfFlag = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_lagou"]];
    imageOfFlag.frame = CGRectMake(150, 110, 90, 150);
    [imageView addSubview:imageOfFlag];
    //用户账号密码
    UIView *viewOfUserPassWord = [[UIView alloc] initWithFrame:CGRectMake(10, 280, 355, 81)];
    viewOfUserPassWord.backgroundColor = [UIColor blackColor];
    [imageView addSubview:viewOfUserPassWord];
    viewOfUserPassWord.alpha = 0.7;
    viewOfUserPassWord.layer.masksToBounds = YES;
    viewOfUserPassWord.layer.cornerRadius = 5;
    
    UITextField *textOfUser = [[UITextField alloc] initWithFrame:CGRectMake(10, 280, 355, 40)];
    UIImageView *image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_username"]];
    image1.backgroundColor = [UIColor blackColor];
    image1.frame = CGRectMake(10, 280, 40, 40);
    textOfUser.leftView = image1;
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, 280, 40, 40)];
    view.backgroundColor = [UIColor blackColor];
    [viewOfUserPassWord addSubview:view];
    textOfUser.leftViewMode = UITextFieldViewModeAlways;
    [imageView addSubview:textOfUser];
    
    UITextField *textOfPassword = [[UITextField alloc] initWithFrame:CGRectMake(10, 321, 355, 40)];
    textOfPassword.backgroundColor = [UIColor blackColor];
    textOfPassword.alpha = 0.8;
    UIView *view0 = [[UIView alloc]initWithFrame:CGRectMake(10, 321, 40, 40)];
    view0.backgroundColor = [UIColor blackColor];
    [imageView addSubview:view0];
    UIImageView *image2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_password"]];
    image2.frame = CGRectMake(10, 315, 30, 30);
    textOfPassword.leftView = image2;
     textOfPassword.leftViewMode = UITextFieldViewModeAlways;
    [imageView addSubview:textOfPassword];
    //登录按钮
    self.buttonOfLogin = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonOfLogin.frame = CGRectMake(10, 380, 355, 40);
    self.buttonOfLogin.backgroundColor = [UIColor colorWithRed:0.18 green:0.8 blue:0.58 alpha:1];
    [imageView addSubview:self.buttonOfLogin];
    [self.buttonOfLogin setTitle:@"登录" forState:UIControlStateNormal];
    [self.buttonOfLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.buttonOfLogin addTarget:self action:@selector(handleButton:) forControlEvents:UIControlEventTouchUpInside];
    //忘记密码
    UIButton *buttonOfMiss = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfMiss.frame = CGRectMake(0, 430, 100, 20);
    [imageView addSubview:buttonOfMiss];
    [buttonOfMiss setTitle:@"忘记密码" forState:UIControlStateNormal];
    [buttonOfMiss setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonOfMiss addTarget:self action:@selector(handleMiss:) forControlEvents:UIControlEventTouchUpInside];
    //现在注册拉钩
    UIButton *buttonOfLaGou = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfLaGou.frame = CGRectMake(130, 480, 120, 30);
    [imageView addSubview:buttonOfLaGou];
    [buttonOfLaGou setTitle:@"现在注册拉钩" forState:UIControlStateNormal];
    buttonOfLaGou.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [buttonOfLaGou setTitleColor:[UIColor colorWithRed:0.2 green:0.8 blue:0.58 alpha:1] forState:UIControlStateNormal];
    [buttonOfLaGou addTarget:self action:@selector(handleLagou:) forControlEvents:UIControlEventTouchUpInside];
    //------or-------
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(10, 540, 150, 1)];
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(220, 540, 150, 1)];
    view1.backgroundColor = [UIColor whiteColor];
    view2.backgroundColor = [UIColor whiteColor];
    [imageView addSubview:view1];
    [imageView addSubview:view2];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(180, 530, 30, 20)];
    label.text = @"or";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont boldSystemFontOfSize:16];
    [imageView addSubview:label];
    //随便逛逛
    UIButton *buttonOfGO = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfGO.frame = CGRectMake(150, 580, 80, 30);
    [buttonOfGO setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [buttonOfGO setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [imageView addSubview:buttonOfGO];
    [buttonOfGO addTarget:self action:@selector(handleGO:) forControlEvents:UIControlEventTouchUpInside];
    
    return YES;
}

- (void)handleButton:(UIButton *)button
{
    NSLog(@"点击了登录按钮");
}
- (void)handleMiss:(UIButton *)button
{
    NSLog(@"点击了忘记密码");
}
- (void)handleLagou:(UIButton *)button
{
    NSLog(@"点击了注册拉钩");
}
- (void)handleGO:(UIButton *)button
{
    NSLog(@"点击了随便逛逛");
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
